﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataBase.ErrorCode
{
    /// <summary>
    /// ApiResult封装
    /// </summary>
    public class ApiResult
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public ApiEnums code { get; set; } = ApiEnums.Fail;
        /// <summary>
        /// 提示信息
        /// </summary>
        public string message { get; set; } = "失败";
        /// <summary>
        /// 返回值
        /// </summary>
        public object data { get; set; }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="message"></param>
        public void Success(string message = "成功")
        {
            this.message = message;
            this.code = ApiEnums.Success;
        }
    }
    /// <summary>
    /// ApiResult封装
    /// </summary>
    public class ApiResult<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public ApiEnums code { get; set; } = ApiEnums.Fail;
        /// <summary>
        /// 提示信息
        /// </summary>
        public string message { get; set; } = "失败";
        /// <summary>
        /// 返回值
        /// </summary>
        public T data { get; set; }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="message"></param>
        public void Success(T data,string message = "成功")
        {
            this.message = message;
            this.code = ApiEnums.Success;
            this.data = data;
        }
    }
}
